package lego.diagram.part;

import java.util.Collections;
import java.util.List;

import lego.diagram.providers.LegoElementTypes;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteGroup;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;

/**
 * @generated
 */
public class LegoPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createLego1Group());
	}

	/**
	 * Creates "lego" palette tool group
	 * @generated
	 */
	private PaletteContainer createLego1Group() {
		PaletteGroup paletteContainer = new PaletteGroup(
				Messages.Lego1Group_title);
		paletteContainer.setId("createLego1Group"); //$NON-NLS-1$
		paletteContainer.add(createRobot1CreationTool());
		paletteContainer.add(createMotorActioner2CreationTool());
		paletteContainer.add(createTouchSensor3CreationTool());
		paletteContainer.add(createLightSensor4CreationTool());
		paletteContainer.add(createMicroSensor5CreationTool());
		paletteContainer.add(createUltraSoundSensor6CreationTool());
		paletteContainer.add(createSensorPortSensor7CreationTool());
		paletteContainer.add(createActionerPortActioner8CreationTool());
		paletteContainer.add(createPicoNet9CreationTool());
		paletteContainer.add(createPicoNetMaster10CreationTool());
		paletteContainer.add(createPicoNetSlaves11CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createRobot1CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Robot1CreationTool_title,
				Messages.Robot1CreationTool_desc,
				Collections.singletonList(LegoElementTypes.Robot_2006));
		entry.setId("createRobot1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(LegoElementTypes
				.getImageDescriptor(LegoElementTypes.Robot_2006));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createMotorActioner2CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.MotorActioner2CreationTool_title,
				Messages.MotorActioner2CreationTool_desc,
				Collections.singletonList(LegoElementTypes.MotorActioner_2007));
		entry.setId("createMotorActioner2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(LegoElementTypes
				.getImageDescriptor(LegoElementTypes.MotorActioner_2007));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createTouchSensor3CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.TouchSensor3CreationTool_title,
				Messages.TouchSensor3CreationTool_desc,
				Collections.singletonList(LegoElementTypes.TouchSensor_2004));
		entry.setId("createTouchSensor3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(LegoElementTypes
				.getImageDescriptor(LegoElementTypes.TouchSensor_2004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createLightSensor4CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.LightSensor4CreationTool_title,
				Messages.LightSensor4CreationTool_desc,
				Collections.singletonList(LegoElementTypes.LightSensor_2005));
		entry.setId("createLightSensor4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(LegoElementTypes
				.getImageDescriptor(LegoElementTypes.LightSensor_2005));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createMicroSensor5CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.MicroSensor5CreationTool_title,
				Messages.MicroSensor5CreationTool_desc,
				Collections.singletonList(LegoElementTypes.MicroSensor_2001));
		entry.setId("createMicroSensor5CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(LegoElementTypes
				.getImageDescriptor(LegoElementTypes.MicroSensor_2001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createUltraSoundSensor6CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.UltraSoundSensor6CreationTool_title,
				Messages.UltraSoundSensor6CreationTool_desc,
				Collections
						.singletonList(LegoElementTypes.UltraSoundSensor_2003));
		entry.setId("createUltraSoundSensor6CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(LegoElementTypes
				.getImageDescriptor(LegoElementTypes.UltraSoundSensor_2003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createSensorPortSensor7CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.SensorPortSensor7CreationTool_title,
				Messages.SensorPortSensor7CreationTool_desc,
				Collections
						.singletonList(LegoElementTypes.SensorPortSensor_4001));
		entry.setId("createSensorPortSensor7CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(LegoElementTypes
				.getImageDescriptor(LegoElementTypes.SensorPortSensor_4001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createActionerPortActioner8CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.ActionerPortActioner8CreationTool_title,
				Messages.ActionerPortActioner8CreationTool_desc,
				Collections
						.singletonList(LegoElementTypes.ActionerPortActioner_4004));
		entry.setId("createActionerPortActioner8CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(LegoElementTypes
				.getImageDescriptor(LegoElementTypes.ActionerPortActioner_4004));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createPicoNet9CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.PicoNet9CreationTool_title,
				Messages.PicoNet9CreationTool_desc,
				Collections.singletonList(LegoElementTypes.PicoNet_2002));
		entry.setId("createPicoNet9CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(LegoElementTypes
				.getImageDescriptor(LegoElementTypes.PicoNet_2002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createPicoNetMaster10CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.PicoNetMaster10CreationTool_title,
				Messages.PicoNetMaster10CreationTool_desc,
				Collections.singletonList(LegoElementTypes.PicoNetMaster_4002));
		entry.setId("createPicoNetMaster10CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(LegoElementTypes
				.getImageDescriptor(LegoElementTypes.PicoNetMaster_4002));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createPicoNetSlaves11CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.PicoNetSlaves11CreationTool_title,
				Messages.PicoNetSlaves11CreationTool_desc,
				Collections.singletonList(LegoElementTypes.PicoNetSlaves_4003));
		entry.setId("createPicoNetSlaves11CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(LegoElementTypes
				.getImageDescriptor(LegoElementTypes.PicoNetSlaves_4003));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List<IElementType> elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(String title, String description,
				List<IElementType> elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List<IElementType> relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(String title, String description,
				List<IElementType> relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
